from __future__ import division
from numpy import median
from math import ceil

# Notes on the algorithm:
#1. I aim to survive, not win.
#2. I don't see any reliable way to recognise other players, so I treat everyone based only on their reputation.
#3. My strategy is to be the average member in the community: I will try to have my reputation as close to median reputation among the remaining players. This I believe is a good survival (but probably not winning) strategy.
#4. The exception to rule #3 is the first round: everybody's rep is 0, but I will try to have a high rep upfront (.9), because I suspect other players will punish slackers.
#5. I will hunt with players with reputation close to mine and slack with those on the extremes: the perennial slackers and hunters.

h, s = 0, 0

def hunt_choices(n, f, rep, m, reps):
    global h, s
    goal_rep = .9 if n == 1 else median(reps)
    num_players = len(reps)
    total_after_round = h + s + num_players
    total_hunts = int(ceil(goal_rep * total_after_round))
    hunts = min(max(total_hunts - h, 0), num_players)
    h += hunts
    s += num_players - hunts
    reps = [(abs(goal_rep - r), i) for i, r in enumerate(reps)]
    reps.sort()
    ret = ['s'] * num_players
    for _, i in reps[: hunts]:
        ret[i] = 'h'
    return ret

def hunt_outcomes(results):
    pass

def round_end(award, m, hunts):
    pass
